using System.ComponentModel.DataAnnotations;
using System.Data.Entity.ModelConfiguration;
using Domain.Entidades;

namespace Data.Models.Mapping
{
    public class usuarioMap : EntityTypeConfiguration<usuario>
    {
        public usuarioMap()
        {
            // Primary Key
            this.HasKey(t => t.usu_codigo);

            // Properties
            this.Property(t => t.usu_nome)
                .HasMaxLength(100);

            this.Property(t => t.usu_login)
                .HasMaxLength(100);

            this.Property(t => t.usu_senha)
                .IsRequired()
                .IsFixedLength()
                .HasMaxLength(16);

            this.Property(t => t.usu_email)
                .HasMaxLength(70);

            this.Property(t => t.usu_tel)
                .HasMaxLength(12);

            this.Property(t => t.usu_icq)
                .HasMaxLength(9);

            this.Property(t => t.usu_ramal)
                .HasMaxLength(4);

            this.Property(t => t.usu_senhaicq)
                .HasMaxLength(50);

            this.Property(t => t.usu_senhaemail)
                .HasMaxLength(50);

            this.Property(t => t.usu_samba)
                .HasMaxLength(30);

            this.Property(t => t.usu_senhasamba)
                .HasMaxLength(30);

            // Table & Column Mappings
            this.ToTable("usuarios");
            this.Property(t => t.usu_codigo).HasColumnName("usu_codigo");
            this.Property(t => t.usu_nome).HasColumnName("usu_nome");
            this.Property(t => t.usu_login).HasColumnName("usu_login");
            this.Property(t => t.usu_senha).HasColumnName("usu_senha");
            this.Property(t => t.usu_unidade).HasColumnName("usu_unidade");
            this.Property(t => t.usu_status).HasColumnName("usu_status");
            this.Property(t => t.usu_cargo).HasColumnName("usu_cargo");
            this.Property(t => t.usu_email).HasColumnName("usu_email");
            this.Property(t => t.usu_datainclusao).HasColumnName("usu_datainclusao");
            this.Property(t => t.usu_datadesligamento).HasColumnName("usu_datadesligamento");
            this.Property(t => t.usu_tel).HasColumnName("usu_tel");
            this.Property(t => t.usu_icq).HasColumnName("usu_icq");
            this.Property(t => t.usu_ramal).HasColumnName("usu_ramal");
            this.Property(t => t.usu_senhaicq).HasColumnName("usu_senhaicq");
            this.Property(t => t.usu_senhaemail).HasColumnName("usu_senhaemail");
            this.Property(t => t.usu_samba).HasColumnName("usu_samba");
            this.Property(t => t.usu_senhasamba).HasColumnName("usu_senhasamba");

            //// Relationships
            //this.HasOptional(t => t.cargo)
            //    .WithMany(t => t.usuarios)
            //    .HasForeignKey(d => d.usu_cargo);
            //this.HasOptional(t => t.status)
            //    .WithMany(t => t.usuarios)
            //    .HasForeignKey(d => d.usu_status);
            this.HasOptional(t => t.unidade)
                .WithMany(t => t.usuarios)
                .HasForeignKey(d => d.usu_unidade);

        }
    }
}
